<template>
  <div class="box">
    <p class="Count">年龄比例</p>
    <p class="top-img"></p>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import * as echarts from "echarts";
let charts = ref();
onMounted(() => {
  let option = {
    tooltip: {
      trigger: "item",
    },
    legend: {
      top: 50,
      right: 10,
      orient: "vertical",
      textStyle: {
        color: "#fff",
      },
    },
    series: [
      {
        name: "Access From",
        type: "pie",
        radius: ["40%", "70%"],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: "#fff",
          borderWidth: 2,
        },
        label: {
          show: true,
          position: "inside",
          color: "#fff",
        },

        labelLine: {
          show: false,
        },
        data: [
          { value: 1048, name: "10岁以下" },
          { value: 735, name: "12岁以上14岁以下" },
          { value: 580, name: "16岁以下" },
          { value: 484, name: "16岁以上18岁以下" },
          { value: 300, name: "18岁以上" },
        ],
      },
    ],
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
    },
  };
  echarts.init(charts.value).setOption(option);
});
</script>

<style scoped lang="scss">
.box {
  background-color: #fff;
  background: url(../../images/dataScreen-main-lt.png) no-repeat;
  background-size: 100% 100%;
  margin-top: 10px;

  color: white;
  .top-img {
    margin-left: 20px;
    width: 67px;
    height: 7px;
    margin-top: 10px;
    background: url(../../images/dataScreen-title.png) no-repeat;
    background-size: 100% 100%;
  }
  .Count {
    margin-left: 20px;
    font-size: 20px;
  }
  .charts {
    height: 260px;
  }
}
</style>
